package yunwo.cn.yzstation.view.activity;

import android.Manifest;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.EditText;
import android.widget.GridView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

import com.google.gson.Gson;
import com.zhy.http.okhttp.callback.StringCallback;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import okhttp3.Call;
import yunwo.cn.yzstation.R;
import yunwo.cn.yzstation.adapter.CarAdapter;
import yunwo.cn.yzstation.adapter.DriverAdapter;
import yunwo.cn.yzstation.adapter.Mygv1Adatper;
import yunwo.cn.yzstation.adapter.MygvAdatper;
import yunwo.cn.yzstation.adapter.ScreenAllAdapter;
import yunwo.cn.yzstation.api.HttpManager;
import yunwo.cn.yzstation.api.IassigmentView;
import yunwo.cn.yzstation.base.MyBaseActivity;
import yunwo.cn.yzstation.base.Yzapp;
import yunwo.cn.yzstation.bean.AssigmnetBean;
import yunwo.cn.yzstation.bean.BatchNumberBean;
import yunwo.cn.yzstation.bean.CarBean;
import yunwo.cn.yzstation.bean.CarOBJBean;
import yunwo.cn.yzstation.bean.ContinueBean;
import yunwo.cn.yzstation.bean.DictionariesBean;
import yunwo.cn.yzstation.bean.DriverBean;
import yunwo.cn.yzstation.bean.EndOrganbean;
import yunwo.cn.yzstation.config.MyConstants;
import yunwo.cn.yzstation.other.PickDialog;
import yunwo.cn.yzstation.other.ShowAnimationDialogUtil;
import yunwo.cn.yzstation.presenter.AssigmentPersenter;
import yunwo.cn.yzstation.utils.SetListViewHeightUtil;
import yunwo.cn.yzstation.utils.StringUtil;
import yunwo.cn.yzstation.zxing.CaptureActivity;

/**
 * Created by lao on 2017/9/2.
 */
public class AssignmentActivity extends MyBaseActivity implements View.OnClickListener, IassigmentView {

    private TextView mScancar;
    private TextView mShoudong;
    private Intent mIntent;
    private LinearLayout mScaninfo;
    private static final int CALL_PHONE_INCODE = 4;
    private static final int ORDER_CODE_INCODEE = 6;
    private ListView mMylistview;
    private EditText mCarnumber;
    private SharedPreferences mCartask_sp;
    private SharedPreferences.Editor mCartask_edit;
    private AssigmentPersenter mAssigmentPersenter;
    private EditText mDriver;
    private EditText mDriverphone;
    private SharedPreferences mDictionariesBean_sp;
    private List<String> mList;
    private HashMap<String, String> mMap;
    private TextView mCartype;
    private PickDialog mHalfScreenDialog;
    private String mCartypeId = "";
    private TextView mBatch;
    private TextView mCarobj;
    private AssigmnetBean mAssigmnetBean;
    private String mContinue;
    ContinueBean.DataBean mDataBean;
    private PickDialog mSelectPayTypeDialog;
    List<CarOBJBean.DataBean> mDataBeanList;
    private MygvAdatper mMygvAdatper;
    String CarobjId = "";
    private String mBeginOrgId;
    private String mType;
    private TextView mObjtv;
    List<EndOrganbean.DataBean> mEndOrganBeanList;
    private Mygv1Adatper mMygv1Adatper;
    private String mOrganType;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        mType = getIntent().getStringExtra("type");

        mCartask_sp = getSharedPreferences("cartask", Context.MODE_PRIVATE);
        mCartask_edit = mCartask_sp.edit();

        mContinue = getIntent().getStringExtra("Continue") == null ? "" : getIntent().getStringExtra("Continue");

        mAssigmentPersenter = new AssigmentPersenter(this, this);
        mAssigmnetBean = new AssigmnetBean();
        initDictionary();
        iniView();
        if (!StringUtil.isEmpty(mContinue)) {
            initContinue();
        } else {
            initData();
        }
    }

    private void initContinue() {
        mScaninfo.setVisibility(View.GONE);
        mCarnumber.setEnabled(false);
        mCartype.setEnabled(false);
        mCarobj.setEnabled(false);
        mDriver.setEnabled(false);
        mDriverphone.setEnabled(false);
        mAssigmentPersenter.getContinueData(mContinue);
    }

    private void initData() {
        mAssigmentPersenter.getLoadingobj();
        mAssigmentPersenter.getBatchNumber();

    }

    private void initDictionary() {
        mDictionariesBean_sp = getSharedPreferences("SP_DICTION", Context.MODE_PRIVATE);
        String zidian = mDictionariesBean_sp.getString("zidian", "");
        if (!zidian.isEmpty()) {
            Gson gson = new Gson();
            mList = new ArrayList<>();
            mMap = new HashMap<>();
            DictionariesBean dictionariesBean = gson.fromJson(zidian, DictionariesBean.class);
            for (int i = 0; i < dictionariesBean.getData().size(); i++) {
                if (dictionariesBean.getData().get(i).getDictCode().equals("VEHICLE_TYPE")) {
                    mList.add(dictionariesBean.getData().get(i).getDictName());
                    mMap.put(dictionariesBean.getData().get(i).getDictName(), dictionariesBean.getData().get(i).getDictValue());
                }
            }

        }

    }


    private void iniView() {
        mMylistview = (ListView) findViewById(R.id.mylistview);
        mDriverphone = (EditText) findViewById(R.id.driverphone);
        mScaninfo = (LinearLayout) findViewById(R.id.scaninfo);
        mScancar = (TextView) findViewById(R.id.scancar);
        mCartype = (TextView) findViewById(R.id.cartype);
        mShoudong = (TextView) findViewById(R.id.shoudong);
        mCarnumber = (EditText) findViewById(R.id.carnumber);
        mDriver = (EditText) findViewById(R.id.driver);
        mBatch = (TextView) findViewById(R.id.batch);
        mCarobj = (TextView) findViewById(R.id.carobj);
        mObjtv = (TextView) findViewById(R.id.objtv);
        mOrganType = Yzapp.getInstance().getOrganType();

        if (mType.equals("1")) {  //短驳
            if (!mOrganType.equals("1003")) {

                mCarobj.setText(Yzapp.getInstance().getgetBeginOrgName());
                mBeginOrgId = Yzapp.getInstance().getBeginOrgId();
                mAssigmnetBean.setCarobj(Yzapp.getInstance().getgetBeginOrgName());
                mAssigmnetBean.setCarobjId(mBeginOrgId);
            } else {
                mCarobj.setOnClickListener(this);
            }
        } else {// 干线
            mAssigmentPersenter.getEndOrgan();
            mObjtv.setText("目的站:");
            mCarobj.setOnClickListener(this);
        }


        if (StringUtil.isEmpty(mContinue)) {
            setWatcherListener(AssignmentActivity.this, mDriver);
            setWatcherListener(AssignmentActivity.this, mCarnumber);
            setWatcherListener(AssignmentActivity.this, mDriverphone);
        }


        mCartype.setOnClickListener(this);
        mShoudong.setOnClickListener(this);
        mScaninfo.setOnClickListener(this);
        mScancar.setOnClickListener(this);
    }

    @Override
    protected String settiltile() {
        mType = getIntent().getStringExtra("type");
        if (mType.equals("1")) {
            return "短驳配载";
        } else {
            return "干线配载";
        }
    }

    @Override
    protected int getLayoutRsid() {
        return R.layout.activity_assignment;
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.carobj:
                mSelectPayTypeDialog = ShowAnimationDialogUtil.showDialog(
                        AssignmentActivity.this, R.layout.carobj_item);
                showBottom(mSelectPayTypeDialog);
                break;
            case R.id.cartype:
                screening("1");
                break;
            case R.id.scancar:
                if (StringUtil.isEmpty(mCarnumber.getText().toString().trim()) || StringUtil.isEmpty(mCartype.getText().toString().trim()) ||
                        StringUtil.isEmpty(mBatch.getText().toString().trim()) || StringUtil.isEmpty(mCarobj.getText().toString().trim())) {

                    Toast.makeText(AssignmentActivity.this, "请完善车辆信息", Toast.LENGTH_SHORT).show();
                    return;
                }
                if (StringUtil.isEmpty(mDriver.getText().toString().trim()) && StringUtil.isEmpty(mDriverphone.getText().toString().trim())) {
                    Toast.makeText(AssignmentActivity.this, "请完善司机信息", Toast.LENGTH_SHORT).show();
                    return;
                }


                mIntent = new Intent(AssignmentActivity.this, ScanAssigAcivity.class);
                if (!StringUtil.isEmpty(mContinue)) {
                    Bundle bundle = new Bundle();
                    bundle.putSerializable("mContinue", mDataBean);
                    mIntent.putExtras(bundle);
                    startActivity(mIntent);
                    finish();
                } else {


                    mAssigmnetBean.setCarnumber(mCarnumber.getText().toString().trim());
                    mAssigmnetBean.setCartype(mCartype.getText().toString().trim());
                    mAssigmnetBean.setCartypeId(mCartypeId);
                    mAssigmnetBean.setBatch(mBatch.getText().toString().trim());
                    mAssigmnetBean.setDriver(mDriver.getText().toString().trim());
                    mAssigmnetBean.setDriverphone(mDriverphone.getText().toString().trim());
                    mAssigmnetBean.setCarobj(mCarobj.getText().toString().trim());

                    mAssigmnetBean.setCarobjId(CarobjId);
                    Bundle bundle = new Bundle();
                    bundle.putSerializable("AssigmentBean", mAssigmnetBean);
                    mIntent.putExtras(bundle);
                    startActivity(mIntent);
                    mCartask_edit.clear().commit();
                    finish();
                }
                break;
            case R.id.shoudong:
                if (StringUtil.isEmpty(mCarnumber.getText().toString().trim()) || StringUtil.isEmpty(mCartype.getText().toString().trim()) ||
                        StringUtil.isEmpty(mBatch.getText().toString().trim()) || StringUtil.isEmpty(mCarobj.getText().toString().trim())) {
                    Toast.makeText(AssignmentActivity.this, "请完善车辆信息", Toast.LENGTH_SHORT).show();
                    return;
                }
                if (StringUtil.isEmpty(mDriver.getText().toString().trim()) && StringUtil.isEmpty(mDriverphone.getText().toString().trim())) {
                    Toast.makeText(AssignmentActivity.this, "请完善司机信息", Toast.LENGTH_SHORT).show();
                    return;
                }
                mIntent = new Intent(AssignmentActivity.this, ShoudongActivity.class);


                if (!StringUtil.isEmpty(mContinue)) {
                    Bundle bundle = new Bundle();
                    bundle.putSerializable("mContinue", mDataBean);
                    mIntent.putExtras(bundle);

                    startActivity(mIntent);
                    finish();
                } else {
                    mAssigmnetBean.setCarnumber(mCarnumber.getText().toString().trim());
                    mAssigmnetBean.setCartype(mCartype.getText().toString().trim());
                    mAssigmnetBean.setCartypeId(mCartypeId);
                    mAssigmnetBean.setBatch(mBatch.getText().toString().trim());
                    mAssigmnetBean.setDriver(mDriver.getText().toString().trim());
                    mAssigmnetBean.setDriverphone(mDriverphone.getText().toString().trim());

                    if (mType.equals("1")) {
                        if (!mOrganType.equals("1003")) {
                            mBeginOrgId = Yzapp.getInstance().getBeginOrgId();
                            mAssigmnetBean.setCarobj(Yzapp.getInstance().getgetBeginOrgName());
                            mAssigmnetBean.setCarobjId(mBeginOrgId);
                        }else {
                            mAssigmnetBean.setCarobj(mCarobj.getText().toString().trim());
                            mAssigmnetBean.setCarobjId(CarobjId);
                        }
                    }



                    Bundle bundle = new Bundle();
                    bundle.putSerializable("AssigmentBean", mAssigmnetBean);
                    mIntent.putExtras(bundle);
                    startActivity(mIntent);
                    mCartask_edit.clear().commit();
                    finish();
                }


                break;
            case R.id.scaninfo:
                if (ContextCompat.checkSelfPermission(AssignmentActivity.this, Manifest.permission.CAMERA)
                        != PackageManager.PERMISSION_GRANTED) {
                    //申请CAMERA权限
                    ActivityCompat.requestPermissions(AssignmentActivity.this, new String[]{Manifest.permission.CAMERA},
                            CALL_PHONE_INCODE);
                } else {
                    Intent intent = new Intent(AssignmentActivity.this, CaptureActivity.class);
                    startActivityForResult(intent, ORDER_CODE_INCODEE);
                }
                break;
        }
    }

    private void showBottom(final PickDialog selectPayTypeDialog) {
        View view = selectPayTypeDialog.getView();
        GridView mygv = (GridView) view.findViewById(R.id.mygv);
        EditText MyTV = (EditText) view.findViewById(R.id.MyTV);


        if (mType.equals("1")) {        //短驳
            mMygvAdatper = new MygvAdatper(AssignmentActivity.this);
            setWatcherListener(AssignmentActivity.this, MyTV);
            mMygvAdatper.refreshDataAndNotifyDataSetChanged(mDataBeanList);
            mygv.setAdapter(mMygvAdatper);
            mygv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                @Override
                public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                    CarOBJBean.DataBean item = (CarOBJBean.DataBean) mMygvAdatper.getItem(i);
                    mCarobj.setText(item.getOrganName());
                    CarobjId = item.getId();
                    selectPayTypeDialog.dismiss();
                }
            });
        } else {   //干线
            mMygv1Adatper = new Mygv1Adatper(AssignmentActivity.this);
            setWatcherListener(AssignmentActivity.this, MyTV);
            mMygv1Adatper.refreshDataAndNotifyDataSetChanged(mEndOrganBeanList);
            mygv.setAdapter(mMygv1Adatper);
            mygv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                @Override
                public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                    EndOrganbean.DataBean item = (EndOrganbean.DataBean) mMygv1Adatper.getItem(i);
                    mCarobj.setText(item.getEndOrganName());
                    CarobjId = item.getEndOrganId();
                    selectPayTypeDialog.dismiss();
                }
            });
        }


    }


    public void screening(final String type) {
        mHalfScreenDialog = ShowAnimationDialogUtil.showDialog(AssignmentActivity.this,
                R.layout.screen_view, Gravity.RIGHT, false, true);
        initHalfScreenView(mHalfScreenDialog, type);
    }

    private void initHalfScreenView(PickDialog dateDialog, final String type) {
        View view = dateDialog.getView();
        TextView titleTV = (TextView) view.findViewById(R.id.titleTV);
        ListView halfScreenLV = (ListView) view.findViewById(R.id.halfScreenLV);
        if ("1".equals(type)) {
            titleTV.setText("车型");
            ScreenAllAdapter screenAllAdapter = new ScreenAllAdapter(mList, AssignmentActivity.this);
            halfScreenLV.setAdapter(screenAllAdapter);
            halfScreenLV.setOnItemClickListener(new AdapterView.OnItemClickListener() {


                @Override
                public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                    setDialogDismiss(mHalfScreenDialog);
                    mCartype.setText(mList.get(position));
                    mCartypeId = mMap.get(mList.get(position));

                }
            });
        }


    }


    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        switch (requestCode) {
            case ORDER_CODE_INCODEE:
                if (resultCode == RESULT_OK) {
                    String orderNo = data.getStringExtra("resultString");
                    Toast.makeText(AssignmentActivity.this, orderNo, Toast.LENGTH_SHORT).show();

                }
                break;
        }
    }

    private void setWatcherListener(final Activity activity, final EditText editText) {
        TextWatcher watchContent = new TextWatcher() {


            private boolean isChanged = false;
            private CharSequence temp;

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                switch (editText.getId()) {
                    case R.id.MyTV:

                        if (mType.equals("1")) {  //短驳
                            String s2 = s.toString();
                            List<CarOBJBean.DataBean> newsBeanList = new ArrayList<>();
                            for (int i = 0; i < mDataBeanList.size(); i++) {
                                if (mDataBeanList.get(i).getOrganName().contains(s2)) {
                                    if (!newsBeanList.contains(mDataBeanList.get(i))) {
                                        newsBeanList.add(mDataBeanList.get(i));
                                    }
                                }
                            }
                            mMygvAdatper.refreshDataAndNotifyDataSetChanged(newsBeanList);
                        } else {  //干线
                            String s2 = s.toString();
                            List<EndOrganbean.DataBean> list = new ArrayList<>();
                            for (int i = 0; i < mEndOrganBeanList.size(); i++) {
                                if (mEndOrganBeanList.get(i).getEndOrganName().contains(s2)) {
                                    list.add(mEndOrganBeanList.get(i));
                                }
                            }
                            mMygv1Adatper.refreshDataAndNotifyDataSetChanged(list);
                        }


                        break;


                    case R.id.carnumber:
                        String mycarnumber = mCarnumber.getText().toString().trim();
                        if (!StringUtil.isEmpty(mycarnumber)) {
                            String SP_carnumber = mCartask_sp.getString("carnumber", "");
                            if (!mycarnumber.equals(SP_carnumber)) {
                                //// TODO: 2017/10/11  请求数据
                                mAssigmentPersenter.requestPopupCon(mycarnumber);
                            } else {
                                mMylistview.setVisibility(View.GONE);
                            }
                        } else {
                            mMylistview.setVisibility(View.GONE);
                        }
                        break;

                    case R.id.driver:
                        String driverphone = "";
                        String mydriver = mDriver.getText().toString().trim();
                        if (!StringUtil.isEmpty(mydriver)) {
                            String SP_driver = mCartask_sp.getString("drivername", "");
                            if (!mydriver.equals(SP_driver)) {
                                if (!StringUtil.isEmpty(mDriverphone.getText().toString())) {
                                    driverphone = mDriverphone.getText().toString().trim();
                                }
                                mAssigmentPersenter.requestDriverPopupCon(mydriver, driverphone);
                            } else {
                                mMylistview.setVisibility(View.GONE);
                            }
                        } else {
                            mMylistview.setVisibility(View.GONE);
                        }
                        break;

                    case R.id.driverphone:
                        String Dvname = "";
                        String s1 = s.toString();
                        Log.d("sssssssss", s1);
                        if (!s1.isEmpty()) {
                            String SP_driverphone = mCartask_sp.getString("driverphone", "");
                            if (!s1.equals(SP_driverphone)) {
                                if (!mDriver.getText().toString().trim().isEmpty()) {
                                    Dvname = mDriver.getText().toString().trim();
                                }
                                mAssigmentPersenter.requestDriverPhonePopupCon(s1, Dvname);
                            } else {
                                mMylistview.setVisibility(View.GONE);
                            }
                        } else {
                            mMylistview.setVisibility(View.GONE);
                        }
                      /*  if (!StringUtil.isEmpty(s1)) {
                            String SP_driverphone = mCartask_sp.getString("driverphone", "");
                            if (!s1.equals(SP_driverphone)) {

                                mAssigmentPersenter.requestDriverPhonePopupCon(s1);
                            }else {
                                mMylistview.setVisibility(View.GONE);
                            }
                        }else {
                            mMylistview.setVisibility(View.GONE);
                        }*/
                        break;
                }

            }

            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            }

            @Override
            public void afterTextChanged(Editable s) {


             /*   switch (editText.getId()) {
                    case R.id.consigneeName:
                        String trim = mConsigneeName.getText().toString().trim();
                        if (!StringUtil.isEmpty(trim)) {
                            String consigneeName = GoodsSP.getInstance().getGoodsShare().getString("consigneeName", "");
                            if (!trim.equals(consigneeName)) {
                                mOrderFragmentPersenter.requestPopupCon("1", trim);
                            } else {
                                mLllistview.setVisibility(View.GONE);
                            }
                        } else {
                            mLllistview.setVisibility(View.GONE);
                        }
                        break;
                    case R.id.consigneePhone:


                        String trim1 = mConsigneePhone.getText().toString().trim();
                        if (!StringUtil.isEmpty(trim1)) {
                            String consigneeName = GoodsSP.getInstance().getGoodsShare().getString("consigneePhone", "");
                            if (!trim1.equals(consigneeName)) {
                                mOrderFragmentPersenter.requestPopupCon("2", trim1);
                            } else {
                                mLllistview.setVisibility(View.GONE);
                            }
                        } else {
                            mLllistview.setVisibility(View.GONE);
                        }

                        break;


                }*/
            }
        };
        editText.addTextChangedListener(watchContent);
    }

    @Override
    public void getDriverPopupConSueecss(final List<DriverBean.DataBean> driverBeanList) {
        if (driverBeanList.size() > 0) {
            mMylistview.setVisibility(View.VISIBLE);
            DriverAdapter driverAdapter = new DriverAdapter(AssignmentActivity.this);
            driverAdapter.refreshDataAndNotifyDataSetChanged(driverBeanList);
            mMylistview.setAdapter(driverAdapter);
            SetListViewHeightUtil.setListViewHeightBasedOnChildren(mMylistview);
            mMylistview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                @Override
                public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                    DriverBean.DataBean dataBean = driverBeanList.get(i);
                    if (dataBean != null) {
                        mCartask_edit.putString("drivername", dataBean.getName());
                        mCartask_edit.putString("driverphone", dataBean.getPhone());
                        mCartask_edit.putString("driverId", dataBean.getId());
                        mCartask_edit.commit();
                        mAssigmnetBean.setDriverId(dataBean.getId());
                        mDriver.setText(dataBean.getName());
                        mDriverphone.setText(dataBean.getPhone());
                        mMylistview.setVisibility(View.GONE);

                    }
                }
            });
        } else {
            mMylistview.setVisibility(View.GONE);
        }
    }

    @Override
    public void getCarPopupConSueecss(final List<CarBean.DataBean> carBeanList) {
        if (carBeanList.size() > 0) {
            mMylistview.setVisibility(View.VISIBLE);
            CarAdapter carAdapter = new CarAdapter(AssignmentActivity.this, mMap);
            carAdapter.refreshDataAndNotifyDataSetChanged(carBeanList);
            mMylistview.setAdapter(carAdapter);
            SetListViewHeightUtil.setListViewHeightBasedOnChildren(mMylistview);
            mMylistview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                @Override
                public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                    CarBean.DataBean dataBean = carBeanList.get(i);
                    if (dataBean != null) {
                        mCartask_edit.putString("carnumber", dataBean.getPlatNumber());
                        mCartask_edit.putString("carId", dataBean.getId());
                        mCartask_edit.putString("cartype", dataBean.getVehicleTypeId());
                        mCartask_edit.commit();
                        mAssigmnetBean.setCarId(dataBean.getId());
                        mCartypeId = dataBean.getVehicleTypeId();
                        mCarnumber.setText(dataBean.getPlatNumber());
                        mCartype.setText(dataBean.getVehicleTypeName());

                    }
                }
            });
        }
    }

    @Override
    public void getBachNumberSuccess(BatchNumberBean.DataBean dataBean) {
        mBatch.setText(dataBean.getBatchNumber() + "");
    }

    @Override
    public void getContinueDataSuccess(ContinueBean.DataBean dataBean) {
        mDataBean = dataBean;
        mCarnumber.setEnabled(false);
        mCartype.setEnabled(false);
        mCarobj.setEnabled(false);
        mDriver.setEnabled(false);
        mDriverphone.setEnabled(false);
        mCarnumber.setText(dataBean.getPlateNumber());
        mCartype.setText(dataBean.getVehicleTypeName());
        mCarobj.setText(dataBean.getTruckTarget());
        mBatch.setText(dataBean.getBatchNumber());
        mDriver.setText(dataBean.getDriverName());
        mDriverphone.setText(dataBean.getDriverPhone());
    }

    @Override
    public void getLoadingobjSuccess(List<CarOBJBean.DataBean> dataBeanList) {
        mDataBeanList = dataBeanList;
    }

    @Override
    public void getEndOrganSuccess(List<EndOrganbean.DataBean> dataBeanList) {
        mEndOrganBeanList = dataBeanList;
    }

    @Override
    public void getEndOrganfailure() {

    }

    private void setDialogDismiss(PickDialog dateDialog) {
        if (dateDialog != null && dateDialog.isShowing()) {
            dateDialog.dismiss();
        }
    }

}
